#
# Imports
#
import sys
import os
import xbmc
import xbmcgui
import xbmcplugin
import xbmczone_constants
#
# Main class
#
class Main:
    def __init__( self ):
        #
        # Plugins
        #
        plugicon = os.path.join( xbmczone_constants.XBMC_HOME_PATH, "resources", "media", "plugin_icon.png" )
        plugthumbnail = os.path.join( os.getcwd(), "resources", "media", "plugin_icon.png" )        
        listitem = xbmcgui.ListItem( xbmc.getLocalizedString(30001), iconImage=plugicon, thumbnailImage=plugthumbnail)
        ok = xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1] ), url = sys.argv[ 0 ] + '?action=plugin-categories', listitem=listitem, isFolder=True)
        
        #
        # Scripts
        #
        scripticon = os.path.join( xbmczone_constants.XBMC_HOME_PATH, "resources", "media", "script_icon.png" )
        scriptthumbnail = os.path.join( os.getcwd(), "resources", "media", "script_icon.png" )         
        listitem = xbmcgui.ListItem( xbmc.getLocalizedString(30002), iconImage=scripticon, thumbnailImage=scriptthumbnail )
        ok = xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url = sys.argv[ 0 ] + '?action=script-categories', listitem=listitem, isFolder=True)
        
        #
        # Latest Addons
        #
        icon = os.path.join( xbmczone_constants.XBMC_HOME_PATH, "resources", "media", "xbmczone_icon.png" )
        thumbnail = os.path.join( os.getcwd(), "resources", "media", "xbmczone_iconBig.png" )
        listitem = xbmcgui.ListItem( xbmc.getLocalizedString(30003), iconImage=icon, thumbnailImage=thumbnail )
        ok = xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url = sys.argv[ 0 ] + '?action=latest-addons', listitem=listitem, isFolder=True)
        
        
        #
        # End of list...
        #
        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )        
